<?php
// 引入redis
$redis=include './redis.php';
if($_POST['username']){
    $username=$_POST['username'];
    if(!$redis->exists($username)){
        $redis->set($username,3600,1);
        header('location:welcome.php');
    }else{
        if($redis->get($username)>=3){
            die("一小时内不能登录三次");
        }else{
            $redis->incr($username);
            header('location:welcome.php');
        }
    }
}
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>用户登录</title>
</head>
<body>
<br>
<div class="container">

    <form action="" method="post" class="form-horizontal" role="form">
        <div class="form-group">
            <label class="col-sm-2 control-label">Label:</label>
            <div class="col-sm-10">
                <input type="text" name="username" class="form-control" value="" autocomplete="off">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-10 col-sm-offset-2">
                <button type="submit" class="btn btn-primary">用户登录</button>
            </div>
        </div>
    </form>

</div>
<script src="../static/js/jquery.min.js"></script>
<script src="../static/js/bootstrap.min.js"></script>
</body>
</html>